package com.hksj.lntm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hksj.common.core.model.Rest;
import com.hksj.lntm.dto.LiquidNitrogenDeviceDTO;
import com.hksj.lntm.dto.LiquidNitrogenDeviceHistoryDTO;
import com.hksj.lntm.service.LiquidNitrogenDeviceService;
import com.hksj.lntm.vo.LiquidNitrogenDeviceHistoryInfoVO;
import com.hksj.lntm.vo.LiquidNitrogenDeviceHistoryVO;
import com.hksj.lntm.vo.LiquidNitrogenDeviceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * @author fjt
 * @data 2024/11/11 8:52
 * @describe
 */
@Api(tags = "液氮罐监测——设备列表")
@RestController
@RequestMapping("/api/lntm/device")
public class LiquidNitrogenDeviceController {


    @Autowired
    private LiquidNitrogenDeviceService liquidNitrogenDeviceService;


    @PostMapping("/page")
    @ApiOperation(value = "分页查询液氮罐设备列表", response = LiquidNitrogenDeviceVO.class)
    public Rest<IPage<LiquidNitrogenDeviceVO>> queryLiquidNitrogenDeviceByPage(@RequestBody LiquidNitrogenDeviceDTO dto){
        return Rest.ok(liquidNitrogenDeviceService.queryLiquidNitrogenDeviceByPage(dto));
    }


    @PostMapping("/historyCurve")
    @ApiOperation(value = "查询指定液氮罐设备历史监测指标趋势图", response = LiquidNitrogenDeviceHistoryVO.class)
    public Rest<List<LiquidNitrogenDeviceHistoryVO>> queryLiquidNitrogenDeviceHistoryCurve(@RequestBody @Valid LiquidNitrogenDeviceHistoryDTO dto){
        return Rest.ok(liquidNitrogenDeviceService.queryLiquidNitrogenDeviceHistoryCurve(dto));
    }


    @PostMapping("/pageHistory")
    @ApiOperation(value = "分页查询指定液氮罐设备历史监测指标详情",response = LiquidNitrogenDeviceHistoryInfoVO.class)
    public Rest<IPage<LiquidNitrogenDeviceHistoryInfoVO>> pageDeviceHistory(@RequestBody @Valid LiquidNitrogenDeviceHistoryDTO dto){
        return Rest.ok(liquidNitrogenDeviceService.pageDeviceHistory(dto));
    }


    @PostMapping("/exportList")
    @ApiOperation(value = "导出指定液氮罐设备历史监测指标详情")
    public void exportList(HttpServletResponse response, @RequestBody @Valid LiquidNitrogenDeviceHistoryDTO dto){
        liquidNitrogenDeviceService.exportList(response, dto);
    }

}
